<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tour.tld" prefix="t" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<t:header login="${sessionScope.login}"/>	
	
	<h3>Tour manager </h3>
	<p>
	
	<jsp:scriptlet> if (request.getAttribute("message") != null) { </jsp:scriptlet>
	<jsp:expression> request.getAttribute("message") </jsp:expression>
	<jsp:scriptlet> request.setAttribute("message", null); } </jsp:scriptlet>
		
	<form action="controller" name="tourVoucherCreation" method="post">
		Country 	<input type="text" name="country"> <p>
		Duration 	<input type="text" name="duration"> days <p> 
		Type: 		
		<p> <input type="radio" name="type" value="Recreation"> Recreation </p>
		<p> <input type="radio" name="type" value="Shopping"> Shopping </p>
		<p> <input type="radio" name="type" value="Sanatorium"> Sanatorium </p>
		
		Transport:	
		<p> <input type="radio" name="transport" value="Train"> Train </p>
		<p> <input type="radio" name="transport" value="Plane"> Plane </p>
		
		Cost 		<input type="text" name="cost">$ <p>
		Last Minute <input type="checkbox" name="lastMinute" value="true"> <p>
		Hotel ID 	<input type="text" name="hotel"> <p>
		<p> <input type="hidden" name="action" value="createTouristVoucher">
		<p> <input type="submit" value="Create Tourist Voucher">
		
	</form>
	
	<form action="controller" name="setLastMinute" method="post">
		Tour ID <input type="text" name="id"> <p>
		Last Minute <input type="checkbox" name="lastMinute" value="true"> <p>
		Cost <input type="text" name="cost"> <p>
		<p> <input type="hidden" name="action" value="updateLastMinute">
		<p> <input type="submit" value="Update">
	</form>  
	<p>
	<form action="controller">
		<input type = "hidden" name = "action" value="loadAllVouchers">
		<input type = "hidden" name = "pageNumber" value="1">
		<input type = "hidden" name = "address" value="TOUR_MANAGER">
 		<input type = "submit" value = "Load All Vouchers">
		
	</form> <p>
	
	<c:if test="${requestScope.entityList ne null}">
		
		<table>
		<tr>
			<th>ID</th>
			<th>Available</th>
			<th>Country</th>
            <th>Duration</th>
            <th>Type</th>
            <th>Transport</th>
            <th>Hotel</th>
            <th>Cost</th>
            <th>Last Minute</th>
		</tr>
	
		<c:forEach items="${requestScope.entityList}" var="entity">
			<t:tour voucher="${entity}"/>
			<p>
		</c:forEach>
		</table>
	
		
		<table border="1" cellpadding="5" cellspacing="5">
        <tr>
            <c:forEach begin="1" end="${requestScope.numberOfPages}" var="i">
             <c:choose>
                    <c:when test="${requestScope.pageNumber eq i}">
                        <td>${i}</td>
                    </c:when>
                    <c:otherwise>
                        <td><a href="controller?action=loadAllVouchers&pageNumber=${i}&address=TOUR_MANAGER">${i}</a></td>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        </tr>
    	</table>
    	
	
	
	<c:if test="${requestScope.pageNumber ne 1}">
			<a href="controller?action=loadAllVouchers&pageNumber=${requestScope.pageNumber-1}&address=TOUR_MANAGER"> Previous </a>
	</c:if>
	
	<c:if test = "${requestScope.pageNumber lt requestScope.numberOfPages}">
    		<a href="controller?action=loadAllVouchers&pageNumber=${requestScope.pageNumber+1}&address=TOUR_MANAGER"> Next </a>
    </c:if>
	
	</c:if>

	
</body>
</html>